package com.yixun.qfbao.model;


import org.apache.commons.codec.digest.DigestUtils;

import java.io.UnsupportedEncodingException;

public class PasswordUtil {

//    public static final String DEFAULT_PWD = "x1234567";

   private static String KEY="qfb_jr_";

//    public static String defaultPwd(){
//        return md5Hex(DEFAULT_PWD);
//    }

   public static String md5Hex(String password){
	   String tempPwd=KEY+password;
	   return DigestUtils.md5Hex(getContentBytes(tempPwd, "utf-8"));
   }
   
   private static byte[] getContentBytes(String content, String charset) {
       if (charset == null || "".equals(charset)) {
           return content.getBytes();
       }
       try {
           return content.getBytes(charset);
       } catch (UnsupportedEncodingException e) {
           throw new RuntimeException("签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset);
       }
   }
}
